<template>
  <div>
    <div class="hc_view">
      <el-dialog
        title="操作确认"
        :visible.sync="dialogVisible"
        lock-scroll
        width="400px"
        :close-on-click-modal="true"
        :before-close="handleClose"
      >
        <div class="dialog_div_1">
          <span>重新选择开账方式</span>
          <span>是否需要保留已录入的基本信息数据？</span>
          <div>
            <el-radio v-model="saveRadio" label="0">保留</el-radio>
            <el-radio v-model="saveRadio" label="-1">不保留</el-radio>
          </div>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="cancel()" size="small">取 消</el-button>
          <el-button type="primary" @click="sure()" size="small">确 定</el-button>
        </span>
      </el-dialog>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dialogVisible: false,
      saveRadio: '0',
    }
  },
  methods: {
    // 用户点击空白或者使用关闭按钮关闭弹窗执行该方法
    handleClose(done) {
      done() // 调用该方法完成后续操作
      this.$emit('onCancel')
    },
    show() {
      this.saveRadio = this.$options.data().saveRadio
      this.dialogVisible = true
    },
    hide() {
      this.dialogVisible = false
    },
    sure() {
      this.$emit('onSure', this.saveRadio)
    },
    cancel() {
      this.hide()
      this.$emit('onCancel')
    },
  },
}
</script>

<style lang="scss" scoped>
.hc_view {
  ::v-deep .el-dialog {
    margin-top: 33vh !important;
    overflow: hidden;
    border-radius: 10px;
    box-shadow: none;
    -webkit-box-shadow: none;

    .el-dialog__body {
      padding: 0;
    }

    .el-dialog__header {
      box-sizing: border-box;
      display: flex;
      align-items: center;
      justify-content: space-between;
      border-bottom: transparent solid 1px;

      span {
        font-size: 0.300019rem;
        color: #666;
        font-weight: 600;
      }

      .el-dialog__headerbtn {
        position: static;

        .el-icon-close {
          color: #999;
          font-size: 0.48753rem;
        }
      }
    }
  }
}

.dialog_div {
  width: 100%;
  display: flex;
  justify-content: center;
  background-color: transparent;

  .dialog_content {
    width: 120px;
    height: 70px;
    background: rgba(229, 246, 255, 1);
    border: 1px solid #91d5fe;
    opacity: 1;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;

    .header_view {
      width: 100%;
      display: flex;
      justify-content: flex-end;
      background: transparent;
      padding: 5px 5px 0 0;

      i {
        font-size: 15px;
        color: #666;
      }
    }

    i {
      font-size: 15px;
      color: #1890fc;
    }
  }
}

.dialog_div_1 {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  span {
    font-size: 14px;
    font-family: PingFang SC-Regular, PingFang SC;
    font-weight: 400;
    color: #666666;
    line-height: 24px;
    &:first-child {
      margin-top: 18px;
    }
  }

  div {
    margin-top: 20px;
  }
}

.dialog-footer {
  margin-top: 24px;
  display: flex;
  justify-content: center;
}
</style>
